From 29dc5ca95cc548e7df5f0eeaae5172e0cbf42356 Mon Sep 17 00:00:00 2001
From: Jerome Brunet <jbrunet@baylibre.com>
Date: Fri, 7 Jul 2017 17:39:21 +0200
Subject: [PATCH] snd: meson: activate HDMI audio path

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 sound/soc/meson/i2s-dai.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/sound/soc/meson/i2s-dai.c b/sound/soc/meson/i2s-dai.c
index 1008af8..63fe098 100644
--- a/sound/soc/meson/i2s-dai.c
+++ b/sound/soc/meson/i2s-dai.c
@@ -56,8 +56,19 @@ struct meson_i2s_dai {
 #define AIU_CLK_CTRL_ALRCLK_RIGHT_J		(2 << 8)
 #define AIU_CLK_CTRL_MORE_I2S_DIV_MASK		GENMASK(5, 0)
 #define AIU_CLK_CTRL_MORE_I2S_DIV(div)		(((div) - 1) << 0)
+#define AIU_CLK_CTRL_MORE_HDMI_TX_SEL_MASK	BIT(6)
+#define AIU_CLK_CTRL_MORE_HDMI_TX_I958_CLK	(0 << 6)
+#define AIU_CLK_CTRL_MORE_HDMI_TX_INT_CLK	(1 << 6)
 #define AIU_CODEC_DAC_LRCLK_CTRL_DIV_MASK	GENMASK(11, 0)
 #define AIU_CODEC_DAC_LRCLK_CTRL_DIV(div)	(((div) - 1) << 0)
+#define AIU_HDMI_CLK_DATA_CTRL_CLK_SEL_MASK	GENMASK(1, 0)
+#define AIU_HDMI_CLK_DATA_CTRL_CLK_DISABLE	(0 << 0)
+#define AIU_HDMI_CLK_DATA_CTRL_CLK_PCM		(1 << 0)
+#define AIU_HDMI_CLK_DATA_CTRL_CLK_I2S		(2 << 0)
+#define AIU_HDMI_CLK_DATA_CTRL_DATA_SEL_MASK	GENMASK(5, 4)
+#define AIU_HDMI_CLK_DATA_CTRL_DATA_MUTE	(0 << 4)
+#define AIU_HDMI_CLK_DATA_CTRL_DATA_PCM		(1 << 4)
+#define AIU_HDMI_CLK_DATA_CTRL_DATA_I2S		(2 << 4)
 #define AIU_I2S_DAC_CFG_PAYLOAD_SIZE_MASK	GENMASK(1, 0)
 #define AIU_I2S_DAC_CFG_AOCLK_32		(0 << 0)
 #define AIU_I2S_DAC_CFG_AOCLK_48		(2 << 0)
@@ -221,6 +232,17 @@ static int meson_i2s_dai_hw_params(struct snd_pcm_substream *substream,
 		return ret;
 	}
 
+	/* Quick and dirty hack for HDMI */
+	regmap_update_bits(priv->core->aiu, AIU_HDMI_CLK_DATA_CTRL,
+			   AIU_HDMI_CLK_DATA_CTRL_CLK_SEL_MASK |
+			   AIU_HDMI_CLK_DATA_CTRL_DATA_SEL_MASK,
+			   AIU_HDMI_CLK_DATA_CTRL_CLK_I2S |
+			   AIU_HDMI_CLK_DATA_CTRL_DATA_I2S);
+
+	regmap_update_bits(priv->core->aiu, AIU_CLK_CTRL_MORE,
+			   AIU_CLK_CTRL_MORE_HDMI_TX_SEL_MASK,
+			   AIU_CLK_CTRL_MORE_HDMI_TX_INT_CLK);
+
 	return 0;
 }
 
